package com.generic.action;

import org.apache.struts2.convention.annotation.Namespace;

import com.generic.dao.impl.ImageDao;
import com.generic.ds.HibernateSession;
import com.generic.module.impl.Image;
import com.generic.module.impl.Member;
import com.opensymphony.xwork2.ActionSupport;

@Namespace("/")
public class Profile extends ActionSupport {
	
	private static final long serialVersionUID = -4001211077091195190L;
	
	private Long id;
	private Member member;
	private Image image;
	
	public Long getId() {
		return id;
	}

	public Member getMember() {
		return member;
	}

	public Image getImage() {
		return image;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	public void setImage(Image image) {
		this.image = image;
	}
	
	public String execute() {
		HibernateSession hs = new HibernateSession();
		try {
			if(id != null) {
				ImageDao imageDao = new ImageDao(hs);			
				image = (Image)imageDao.find(id);
			}			
		} catch (Exception e) {
			hs.rollbackTransaction(e);
		} finally {
			hs.closeSession();
		}
		return SUCCESS;
	}
}
